<?php
/**
 * common repository file Created by PhpStorm.
 * User: yang
 * Date: 2020/04/27
 */

namespace Common\Repository;

class PublicRepository extends BaseRepository
{
    /**
     * 根据条件检测数据是否存在
     * @param string $table
     * @param array $where
     * @param null $id
     * @return mixed
     */
    public function countNum($table = '', $where = [], $id = null)
    {
        $modelObj = '\Common\Model\\' . $table;
        $model = new $modelObj();
        if ($id) {
            $model = $model->where('id', '!=', (int)$id);
        }

        return $model->where($where)->count();
    }
}